using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

public partial class BlockDebugFloating : Floating
{
    DataListCreatorV2 list;
    private void Awake()
    {
        this.list = this.GetComponent<DataListCreatorV2>();
        this.list.ViewCreated += List_ViewCreated;
    }

    private void List_ViewCreated(RectTransform arg1, object arg2)
    {
        var text = arg1.GetComponent<Text>();
        var blockKey = arg2 as string;
        text.text = blockKey;
    }

    protected override void Refresh()
    {
        var keyList = BlockManager.Stuff.keyToIsBlockDic.Keys;
        if(keyList.Count == 0)
        {
            this.gameObject.SetActive(false);
        }
        else
        {
            this.gameObject.SetActive(true);
            this.list.Reset(keyList);
        }

    }
}
